home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / prog / graphics / blue.c < prev    next >
C/C++ Source or Header  |  1994-08-05  |  729b  |  48 lines

  1. #include <fstream.h>
  2. #include <LEDA/list.h>
  3. #include <LEDA/window.h>
  4.  
  5.  
  6. main(int argc, char** argv)
  7. {  
  8.  
  9.    ifstream colors("/usr/lib/X11/rgb.txt");
  10.  
  11.    int r,g,b;
  12.    char c;
  13.    string s;
  14.  
  15.    string pat = "blue";
  16.  
  17.    if (argc > 1) pat = argv[1];
  18.  
  19.    list<string> L;
  20.  
  21.    while (colors >> r >> g >> b >> c)
  22.    { colors.putback(c);
  23.      s = read_line(colors);
  24.      if (s.pos(pat) != -1) L.append(s);
  25.     }
  26.  
  27.    int n = L.length();
  28.  
  29.    window W(500,500);
  30.  
  31.    W.init(0,n,0);
  32.    W.set_show_coordinates(false);
  33.  
  34.    int i = 0;
  35.    forall(s, L) 
  36.    { cout << s << endl;
  37.      W.draw_filled_rectangle(i,0,i+1,n,color(~s));
  38.      //W.draw_rectangle(i,0,i+1,n,black);
  39.      i++;
  40.     }
  41.     cout << i << endl;
  42.  
  43.     W.read_mouse();
  44.  
  45.   return 0;
  46. }
  47.   
  48.